package com.situ.mybatis.test;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import com.situ.mybatis.entity.Banji;
import com.situ.mybatis.entity.Student;
import com.situ.mybatis.mapper.IBanjiDao;
import com.situ.mybatis.mapper.IStudentDao;
import com.situ.mybatis.util.myBatisUtil;

public class MyBatisTest3 {
	
	@Test
	public void test1() {
		SqlSession sqlSession = myBatisUtil.getSqlSession();
		IStudentDao studentDao = sqlSession.getMapper(IStudentDao.class);
		List<Student>list = studentDao.one2oneList();
		
		for (Student student : list) {
			System.out.println(student);
			// Student [id=33, name=superadmin, age=99, gender=女, banji=Banji [id=33, name=java1807]]
			// ${student.name}
			// ${student.banji.name}
		}
	}
	@Test
	public void test2() {
		SqlSession sqlSession = myBatisUtil.getSqlSession();
		IBanjiDao banjiDao = sqlSession.getMapper(IBanjiDao.class);
		Banji banji = banjiDao.one2ManyList(2);
			System.out.println(banji);
			// Student [id=33, name=superadmin, age=99, gender=女, banji=Banji [id=33, name=java1807]]
			// ${student.name}
			// ${student.banji.name}
	}
	@Test
	public void test3() {
		SqlSession sqlSession = myBatisUtil.getSqlSession();
		IBanjiDao banjiDao = sqlSession.getMapper(IBanjiDao.class);
		List<Banji>list = banjiDao.selectBanjiCourseInfo();
		 
		for (Banji banji : list) {
			System.out.println(banji);
		}
	}
}
